<?php 
include('../../Connections/KRAPPERCON.php');
$oper = getVal('oper');

if ($oper == 'load'){
$centro = getVal('centro');
$sql = "call sp_getAllNumeradores('".$centro."')";
$res = $mysqli->query($sql);

if ($res){
?>
<table width="100%" border="1" cellspacing="0" rules="all" class="tableIn" cellpadding="0">
<thead>
  <tr>
    <th>Numerador</th>
        <th>Prefijo</th>
    <th>Ult.Documento</th>
    <th>&nbsp;</th>
    </tr>
  </thead>
  <tbody>
  <?php 
  while($row = $res->fetch_assoc()){
  ?>
  <tr title="<?php echo $row['CentroID']; ?>">
    <td class="clsNumID" title="<?php echo $row['NumerID'];?>"><?php echo $row['NumerNom'];?></td>
        <td><input type="text" class="clsNumPre" value="<?php echo $row['NumerPre']; ?>" maxlength="10"></td>
    <td><input type="text" class="qt clsNumVal" value="<?php echo $row['NumerVal']; ?>" maxlength="10"></td>
    <td>
      <input type="submit" name="button" id="button" value="Guardar" onClick="saveNumer(this)">
    </td>
    </tr>
  <?php 
  }
  ?>
</tbody>
</table>

<?php 
$res->close();
$mysqli->next_result();
}
}
elseif ( $oper == 'upd'){
$centro = getVal('centro');
$ident = getVal('id');
$numer = getVal('numer');
$prefix = getVal('prefix');

$sql = "call sp_updDatosNumer('".$centro."','".$ident."','".$prefix."','".$numer."');";
doEcho($sql);
$res = $mysqli->query($sql);

if ($res){
	if ($row = $res->fetch_assoc()){
		$nro = $row['newnro'];
		if ($row > 0 ){
			echo "<script type='text/javascript'>showOk('Cambios guardados satisfactoriamente');</script>";		
		}
		else {
			echo "<script type='text/javascript'>showError('".$row['msg_err']."');</script>";
		}
	}
$res->close();
$mysqli->next_result();
}

}
?>